package com.hongye.app.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class AppVersionModel extends Model<AppVersionModel>{

	private static final long serialVersionUID = 8556184183660891837L;
	public static final AppVersionModel dao = new AppVersionModel();
	
	/**
	 * 获取版本更新列表
	 * @author lifuqiang
	 * 2017-3-24
	 * @return
	 */
	public static List<AppVersionModel> getVersionList(){
		String sql = "select * from version order by c_time desc";
		List<AppVersionModel> list = dao.find(sql);
		return list;
	}
	/**
	 * 获取android 或ios当前版本号
	 * @author liushaomin
	 * 2017年3月24日
	 * @param type
	 * @return
	 */
	public static AppVersionModel getVersion(String type) {
		AppVersionModel version = dao.findFirst("select * from version where type = '"+type+"' ORDER BY c_time DESC LIMIT 0,1");
		return version;
	}
	
	/**
	 * 通过平台、版本号判断是否存在该版本
	 * @author lifuqiang
	 * 2017-3-24
	 * @param type
	 * @param version_number
	 * @return
	 */
	public static boolean isExistVersion(String type, String version_number){
		String sql = "select * from version where type = '"+type+"' and version_number = '"+version_number+"'";
		List<AppVersionModel> list = dao.find(sql);
		boolean boo = false;
		if(list.size()>0){
			boo = true;
		}
		return boo;
	}
	
}
